package com.jr.service.impl;

import com.jr.entry.BookInfo;
import com.jr.entry.Users;
import com.jr.mapper.UsersMapper;
import com.jr.pojo.BookType;
import com.jr.pojo.IsBorrwo;
import com.jr.service.UsersService;
import com.jr.util.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class UserServiceImpl implements UsersService {
    @Autowired
    private UsersMapper usersMapper;

    @Override
    public Users login(Users users) {
        return usersMapper.selectUsersByInfo(users);
    }

    @Override
    public List<BookInfo> findBookInfo(BookInfo bookInfo) {
        return usersMapper.selectBookInfo(bookInfo);
    }

    @Override
    public List<IsBorrwo> findByIsBorrwo() {
        return usersMapper.selectByIsBorrwo();
    }

    @Override
    public List<BookType> findByBookType() {
        return usersMapper.selectByIsNameType();
    }

    @Override
    public boolean addBookInfo(BookInfo bookInfo) {
        return usersMapper.insertBookInfo(bookInfo)==1?true:false;
    }

    @Override
    public boolean updateBookInfo(BookInfo bookInfo) {
        return usersMapper.updateBookInfo(bookInfo)==1?true:false;
    }

    @Override
    public boolean removeBookInfo(String book_code) {
        return usersMapper.deleteBookInfo(book_code)==1?true:false;
    }

    @Override
    public ArrayList<BookInfo> findBookInfoByQueryAndIndex(BookInfo bookInfo, PageHelper pageHelper) {
        return usersMapper.selectBookInfoByQueryAndIndex(bookInfo,pageHelper);
    }


}
